package com.sh.job.snailjob;

import cn.hutool.core.lang.Dict;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import com.sh.business.domain.dto.JobDto;
import com.sh.business.service.IUserService;
import com.sh.business.service.facade.UserServiceFacade;
import com.sh.common.json.utils.JsonUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author ruoyi
 * @date 2024-05-17
 */
@RequiredArgsConstructor
@Component
@JobExecutor(name = "DailyDynamicSzpnAnnoJobExecutor")
public class DailyDynamicSzpnAnnoJobExecutor {

    private final UserServiceFacade userServiceFacade;

    public ExecuteResult jobExecute(JobArgs jobArgs) {
        SnailJobLog.LOCAL.info("dailyFinancingAnnoJobExecutor. jobArgs:{}", JsonUtil.toJsonString(jobArgs));

        Dict dict = JsonUtils.parseMap(JsonUtil.toJsonString(jobArgs));
        Object jobParams = dict.getObj("jobParams");

        JSONObject jsonObject = JSONUtil.parseObj(jobParams);
        String orderSn = jsonObject.getStr("orderSn");

        userServiceFacade.szpnDynamics(orderSn);

        SnailJobLog.REMOTE.info("dailyFinancingAnnoJobExecutor. jobArgs:{}", JsonUtil.toJsonString(jobArgs));
        return ExecuteResult.success("成功");
    }
}
